package com.paishen.peiniwan.frame;

import android.animation.TypeEvaluator;
import android.graphics.Color;

/**
 * Created by Administrator on 2015/12/1.
 */
public class ColorEvaluator implements TypeEvaluator<Integer> {
    @Override
    public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
        int startColor = (int) startValue;
        int endColor = (int) endValue;

        int alpha = (int) (Color.alpha(startColor) + fraction *
                (Color.alpha(endColor) - Color.alpha(startColor)));
        int red = (int) (Color.red(startColor) + fraction *
                (Color.red(endColor) - Color.red(startColor)));
        int green = (int) (Color.green(startColor) + fraction *
                (Color.green(endColor) - Color.green(startColor)));
        int blue = (int) (Color.blue(startColor) + fraction *
                (Color.blue(endColor) - Color.blue(startColor)));

        return Color.argb(alpha, red, green, blue);
    }
}